#include "defines.h"
#include "delay.h"

#define ABWCR   ((volatile uint8 *)0xfee020)
#define ASTCR   ((volatile uint8 *)0xfee021)
#define WCRH    ((volatile uint8 *)0xfee022)
#define WCRL    ((volatile uint8 *)0xfee023)
#define BCR     ((volatile uint8 *)0xfee024)

#define DRCRA   ((volatile uint8 *)0xfee026)
#define DRCRB   ((volatile uint8 *)0xfee027)
#define RTMCSR  ((volatile uint8 *)0xfee028)
#define RTCNT   ((volatile uint8 *)0xfee029)
#define RTCOR   ((volatile uint8 *)0xfee02a)

int dram_init()
{
    *ABWCR = 0xff;
    *RTCOR = 31;
    *RTMCSR = 0x17;
    *DRCRB = 0x98;
    *DRCRA = 0x30;
        
    *WCRH = 0xff;
    *WCRL = 0xcf;
    *ASTCR = 0xfb;    

    delay_ms(50); /* 安定待ち。入れないとまともに働かない */

    return 0;
}
